#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <stdio.h>
#define MAX_SIZE 65550
#define MIN_SIZE 200
void createSocket(){
    int sock = socket(AF_INET,SOCK_DGRAM,0);
    struct sockaddr_in peeraddr;
    peeraddr.sin_addr.s_addr = inet_addr("192.168.1.121");
    peeraddr.sin_family = AF_INET;
    peeraddr.sin_port = htons(5558);

    //bind(socket,(struct sockaddr*)&peeraddr,sizeof(peeraddr));
    ssize_t t = 0;
    char p[MAX_SIZE] ={0};
    char c[MIN_SIZE] = {0};
    int i  = 0,j = 0;
    for(i= 0;i<10;i++){
        for(j = 0;j<MAX_SIZE;j++){
            p[j] = i;
        }
        t = sendto(sock,p,MAX_SIZE,0,(struct sockaddr*)(&peeraddr),sizeof(peeraddr));
    printf("send %d success\n",i);
    }
//    socklen_t len;
//    for(int i = 0;i<10;i++)
//    {
//        recvfrom(socket,p,MAX_SIZE,0,(struct sockaddr*)&peeraddr,&len);
//        LogE("count i: %d recv code is :%s",i,p);
//    }
}
void* run(void* data){
    createSocket();
    return NULL;
}

void test(){
    pthread_t pt;
    pthread_create(&pt,NULL,run,NULL);
    pthread_join(pt,NULL);
}
int main(){
    test();
    return 0;	
}
